package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.ComplainMapper;
import com.xxx.modules.entity.Complain;
import com.xxx.modules.service.ComplainService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * complain
 *
 * @author 北易航
 * @since 1.0.0 2022-12-28
 */
@Service
public class ComplainServiceImpl extends ServiceImpl<ComplainMapper, Complain> implements ComplainService {

    @Autowired
    private ComplainMapper complainMapper;


    @Override
    public PageInfo<Complain> selectComplainInfo(Complain complain, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Complain> wrapper = new QueryWrapper<>();
        List<Complain> data = complainMapper.selectListInfo(complain);
        return new PageInfo<>(data);
    }

    @Override
    public void saveComplainInfo(Complain complain) {
        complain.setCreateTime(TimeUtil.getCurrentTime());
        complainMapper.insert(complain);
    }

    @Override
    public void updateComplainInfo(Complain complain) {
        complainMapper.updateById(complain);
    }

    @Override
    public void delComplainInfo(Integer id) {
        complainMapper.deleteById(id);
    }

    @Override
    public void delBatchComplainInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        complainMapper.deleteBatchIds(list);
    }


}